from twisted.python import log
from twisted.web import xmlrpc, server

log.startLogging(file('server.log','a'))
PORT=7777

class RemoteService(xmlrpc.XMLRPC):
  def xmlrpc_foo(self, x):
    log.msg("RemoteService.foo(%s)\n"%(x))
    return x

  def xmlrpc_add(self, a, b):
    log.msg("RemoteService.add(%d,%d)\n"%(a,b))
    return a + b

def runServer():
  from twisted.internet import reactor
  r = RemoteService()
  reactor.listenTCP(PORT, server.Site(r))
  log.msg("Listening on port(%d)"%(PORT))
  reactor.run()
  log.msg("Reactor loop terminated")


def main():
  runServer()

if __name__ == '__main__':
  main()

